﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PolyCrypt
{
    delegate ContainerControl ControlFactory();
    internal class CryptProvider
    {
        private readonly string name;
        private readonly string imageKey;
        private readonly ControlFactory factory;
        private ContainerControl control;
        public CryptProvider(string name, ControlFactory factory)
        {
            this.name = name;
            this.imageKey = name.ToLower() + ".png";
            this.factory = factory;
        }
        public string Name { get { return name; } }
        public ContainerControl Control { get { 
                if(control == null)
                {
                    control = factory();
                }
                return control; 
            } 
        }
        public string ImageKey { get {  return imageKey; } }
    }
    internal class CryptHelper
    {
        private static readonly IReadOnlyList<CryptProvider> cryptProviders = initCryptProviders();
        private static IReadOnlyList<CryptProvider> initCryptProviders()
        {
            var result = new List<CryptProvider>
            {
                new CryptProvider("RSA", () => new RsaCrypt()),
                new CryptProvider("DES", () => new DesCrypt())
            };
            return result;
        }
        public static IReadOnlyList<CryptProvider> getCryptProviders()
        {
            return cryptProviders;
        }
    }
}
